
<%= link_to '编辑', edit_customer_path(@customer) %> |
<%= link_to '返回', customers_path %>

<h4>客户信息</h4>

<table id="no-more-tables" class="table table-striped table-bordered no-more-tables">
  <thead>
  <tr>
    <th>编号</th>
    <th>名称</th>
    <th>手机</th>
    <th>邮箱</th>
    <th>微信号</th>
    <th>地址</th>
    </tr>
  </thead>
  <tbod>
    <tr>
      <td data-title="编号"><%= @customer.id %></td>
      <td data-title="名称"><%= @customer.name %></td>
      <td data-title="手机"><%= link_to @customer.phone, "tel:#{@customer.phone}" %></td>
      <td data-title="邮箱"><%= @customer.email %></td>
      <td data-title="微信号"><%= @customer.wechat %></td>
      <td data-title="地址"><%= @customer.full_address %></td>
    </tr>
  </tbod>
</table>

<% if @customer.has_car %>
<h4>车辆信息</h4>

<table id="no-more-tables2" class="table table-striped table-bordered no-more-tables">
  <thead>
  <tr>
    <th>身份证号</th>
    <th>车牌号</th>
    <th>车架号</th>
    <th>发动机号</th>
    <th>注册时间</th>
    <th>上一家保险公司</th>
  </tr>
  </thead>
  <tbod>
    <tr>
      <td data-title="身份证号"><%= @customer.car.id_card_no %></td>
      <td data-title="车牌号"><%= @customer.car.license_plate_no %></td>
      <td data-title="车架号"><%= @customer.car.body_no %></td>
      <td data-title="发动机号"><%= @customer.car.engine_no %></td>
      <td data-title="注册时间"><%= @customer.car.registered_at.try(:strftime, '%F') %></td>
      <td data-title="上一家保险公司"><%= @customer.car.last_insurance_company %></td>
    </tr>
  </tbod>
</table>
<% end %>

<h4>客户购买的产品</h4>

<table class="table table-striped table-bordered">
  <thead>
  <tr>
    <th>产品名称</th>
    <th>销售时间</th>
    <th>数量</th>
    <th>到期时间</th>
    <th>销售</th>
  </tr>
  </thead>

  <tbody>
  <% @sales.each do |sale| %>
      <tr>
        <td><%= sale.product.name %></td>
        <td><%= sale.sold_at.strftime('%F') %></td>
        <td><%= sale.product_number %></td>
        <td><%= sale.product_expired_at.try(:strftime, '%F') %></td>
        <td><%= sale.staff.name_or_email %></td>
      </tr>
  <% end %>
  </tbody>
</table>

<%= paginate @sales, :theme => 'twitter-bootstrap-3' %>
